<?php
class Acl_Auth_Auth 
{
	protected $db;
	
	function __construct($database)
	{
		$this->db=Acl_Mysql_Connect::getInstance($database);
		
	}
	
	public function loginUser($data)
	{
		$user=NULL;
		$sql="SELECT id, name, email  
			  FROM users 
			  WHERE email='".$data['email']."' AND 
					password='".sha1($data['password'])."'";
		echo $sql;
		$user=$this->db->fetchOneArray($sql);
		// Recorrido OK
		if($user)
		{
			$_SESSION['email']=$user['email'];
			return $user;
		}
		// Recorrido KO
		else		
		{		
			// TODO: parametrizar	
			if(isset($_SESSION['ip']) AND $_SESSION['ip']==10)
			{
				$ip=new Acl_Ips_Ip($_SERVER['REMOTE_ADDR']);				
				$ip->insertIp(); // Recorrido Bloquear
			}
			else
			{
				$_SESSION['ip']++;
			}
			
			return FALSE;
		}				
		
	}
}